﻿using System;
using Lottery.App.Model;
using System.Collections.Generic;

namespace Lottery.App.DAL
{
    public class P3Dao : ResultDao<P3Info>
    {
        protected override IList<P3Info> GetItems(RecordInfo record)
        {
            return Session.CreateQuery("from P3Info where Value = ?")
                .SetString(0, record.P3)
                .List<P3Info>();
        }

        protected override int GetLastID(string value)
        {
            string hql = "select Max(r.id) from RecordInfo r where P3 = ?";

            return Session.CreateQuery(hql)
                .SetString(0, value)
                .UniqueResult<int>();
        }

        internal override IList<RecordInfo> List(string value)
        {
            string hql = "from RecordInfo where P3 = ?";

            return Session.CreateQuery(hql)
                .SetString(0, value)
                .List<RecordInfo>();
        }

        public override IList<int> GetIds(string value)
        {
            string hql = "select r.id from RecordInfo r where P3 = ?";

            return Session.CreateQuery(hql)
                .SetString(0, value)
                .List<int>();
        }
    }
}
